﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>人员-部门列表</title>
    <script type="text/javascript" src="../WF/Scripts/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../WF/Scripts/jquery/jquery.easyui.min.js"></script>
    <script src="../WF/Scripts/QueryString.js" type="text/javascript"></script>
    <!-- 引入新版本的类库. -->
    <script src="../WF/Scripts/config.js" type="text/javascript"></script>
    <script src="../WF/Comm/Gener.js" type="text/javascript"></script>
    <link href="../WF/Scripts/layui/layui/css/modules/layer/default/layer.css" rel="stylesheet" />
    <script src="../WF/Scripts/layui/layui/lay/modules/layer.js"></script>
    <script src="../WF/Scripts/layui/LayuiDialog.js"></script>

    <script type="text/javascript">
        var webUser = new WebUser();
        $(function () {

            $("#Msg").html("正在加载请稍候...");

            var empNo = GetQueryString("FK_Emp");
            var emp = new Entity("BP.Port.Emp", empNo);

            //隶属的部门.
            var des = new Entities("BP.Port.DeptEmps");
            des.Retrieve("FK_Emp", empNo);

            //隶属的部门岗位.
            var dess = new Entities("BP.Port.DeptEmpStations");
            dess.Retrieve("FK_Emp", empNo);

            var html = "<table border=0 style='width:100%;'>";
            html += "<caption >姓名:" + emp.Name + ", 主部门:" + emp.FK_DeptText + " <a href='javascript:AddDept()'>增加部门</a></caption>";
            html += "<tr>";
            html += "<th>部门</th>";
            html += "<th>部门名称</th>";
            html += "<th>岗位</th>";
            html += "<th>操作</th>";
            html += "</tr>";

            for (var i = 0; i < des.length; i++) {

                var deptEmp = des[i];
                html += "<tr>";
                html += "<td>" + deptEmp.FK_Dept + "</td>";

                var dept = new Entity("BP.Port.Dept", deptEmp.FK_Dept);
                html += "<td>" + dept.Name + "</td>";

                var lab = "";
                for (var idx = 0; idx < dess.length; idx++) {
                    var en = dess[idx];
                    if (en.FK_Dept == deptEmp.FK_Dept) {

                        var sta = new Entity("BP.Port.Station", en.FK_Station);

                        lab += sta.Name + ',';
                    }
                }
                if (lab == "")
                    lab = "无岗位-增加";

                html += "<td><a href=\"javascript:AddStation('" + deptEmp.FK_Dept + "','" + empNo + "')\">" + lab + "</a></td>";
                html += "<td><a href=\"javascript:Del('" + deptEmp.MyPK + "')\" ><img src='../WF/Img/Btn/Delete.png' title='删除' alt='删除'></a></td>";
                html += "</tr>";
            }

            html += "</table>";

            $("#Msg").html(html);
            $(".showTD").on("mouseover", function () {
                var innerHtml = this.innerHTML;
                if (innerHtml.endsWith("...") == false)
                    return;
                var that = this;
                var text = $(this).attr("data-info");
                layer.tips(text, that, {
                    maxWidth: text.length * 10,
                    tips: 1,
                    time: 0
                });

            });
            $(".showTD").on("mouseout", function () {
                layer.closeAll();
            });



        });

        //修改主部门.
        function EditMainDept() {

            var empNo = GetQueryString("FK_Emp");
            var emp = new Entity("BP.Port.Emp", empNo);
            SetHref("EmpDeptMainDept.htm?FK_Emp=" + empNo + "&FK_DEPT=" + emp.FK_Dept);


        }

        //设置主部门
        function SetMainDept(deptNo, empNo) {

            var emp = new Entity("BP.Port.Emp", empNo);
            emp.FK_Dept = deptNo;
            emp.Update();
            Reload();

        }

        //设置岗位.
        function AddStation(deptNo, empNo) {
            var url = "EmpDeptsDtl.htm?FK_Emp=" + empNo + "&FK_Dept=" + deptNo;
            var W = document.body.clientWidth - 200;
            OpenLayuiDialog(url, "设置岗位", W, 100, "auto", true);
            //SetHref(url);
        }


        function AddDept() {

            var empNo = GetQueryString("FK_Emp");

            var url = "../../WF/Comm/RefFunc/Branches.htm?EnName=BP.GPM.GPMEmp&Dot2DotEnsName=BP.Port.DeptEmps&Dot2DotEnName=BP.Port.DeptEmp&AttrOfOneInMM=FK_Emp&AttrOfMInMM=FK_Dept&EnsOfM=BP.Port.Depts&DefaultGroupAttrKey=&No=" + empNo + "&PKVal=" + empNo;
            if (plant != "CCFlow")
                url = basePath + "/WF/Comm/RefFunc/Branches.htm?EnName=BP.GPM.GPMEmp&Dot2DotEnsName=BP.Port.DeptEmps&Dot2DotEnName=BP.Port.DeptEmp&AttrOfOneInMM=FK_Emp&AttrOfMInMM=FK_Dept&EnsOfM=BP.Port.Depts&DefaultGroupAttrKey=&No=" + empNo + "&PKVal=" + empNo;
            var W = document.body.clientWidth - 200;
            OpenLayuiDialog(url, "增加部门", W, 100, "auto", true);
            // SetHref(url);
        }

        function Del(mypk) {

            if (window.confirm('您确定要删除吗？') == false)
                return;

            var dept = new Entity("BP.Port.DeptEmp", mypk);
            dept.Delete();

            Reload();
        }
    </script>

    <link href="../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />

</head>
<body>


    <div id="Msg"></div>

</body>
</html>
